import { Inject, Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';

@Injectable()
export class InitDbService implements OnModuleInit {
  constructor(
    private readonly discoveryService: DiscoveryService,
    private readonly metadataScanner: MetadataScanner
  ) {}
  onModuleInit() {
    this.collectionsPermission();
  }

  private collectionsPermission() {
    console.log('开始收集权限');
    // const providers: InstanceWrapper[] = this.discoveryService.getProviders();
    // providers.forEach((wrapper: InstanceWrapper) => {
    //   const { instance } = wrapper;
    //   if (!instance) {
    //     return;
    //   }
    //   console.log(instance);
    // });
    // const cls = Reflect.getMetadata(PERMISSION_MODULE, '');
    // console.log(cls);
    // const mothod = Reflect.getMetadata(REDIS_CACHE_KEY, context.getClass());
  }
}
